<?php
/**
 * @author Laurent SITTLER <lolo.sittler@gmail.com>
 * @author Alexandre GOMEZ <gomez.alexandre02@gmail.com>
 * @version 0.1
 */
require_once 'User.php';

/**
 * View Class
 */
class View {
    
    /**
     * Create View
     */
    function __construct() {
        
        $this->m_view = 'Default';
        $this->m_cuser = new User();
    }
    
    /**
     * Set view in render
     * @param String $view
     */
    public function SetView($view){
        $this->m_view = $view;
    }
    
    /**
     * Set current user in interface
     * @param User $user
     */
    public function SetUser(User $user){
        $this->m_cuser = $user;
    }

    /**
     * Show view
     * @param Page $name
     * @param Boolean $noInclude
     */
    public function render($noInclude = false) {
        $file = 'View/' . $this->m_view . '.php';
        if ($noInclude == true) {
            if (file_exists($file)) {
                require $file;
            } else {
                throw new Exception('Page introuvable');
                return false;
            }
        } else {
            if (file_exists($file)) {
                require $file;
            } else {
                throw new Exception('Page introuvable');
                return false;
            }
        }
        $this->m_cuser;
    }
    
    /**
     * View Element
     * @var View | Default
     */
    private $m_view;
    
    /**
     * Current User
     * @var User 
     */
    private $m_cuser;
    
}